

import 'dart:ffi';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:study_flutter/home/home.dart';
import 'package:study_flutter/image/image.dart';
import 'package:study_flutter/me/me.dart';

class MainTabbarWidget extends StatefulWidget{
  @override
  State<MainTabbarWidget> createState() {
    return _MainState();
  }

}

class _MainState extends State<MainTabbarWidget>{
  var _currentIndex = 0;
  List<StatefulWidget> _pageChildren = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _pageChildren = [
      HomePage(),
      ImagePage(),
      MePage(),
    ];
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:_pageChildren[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home),label: "首页"),
          BottomNavigationBarItem(icon: Icon(Icons.image),label: "图片"),
          BottomNavigationBarItem(icon: Icon(Icons.person),label:"我的")
        ],
        onTap: onChangePage,
      ),
    );
  }

  void onChangePage(int index){
    setState(() {
      _currentIndex = index;
    });
  }

}